<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('优惠券明细')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <input type="hidden" id="memberId" value="" th:value="${memberId}">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>

                        <p>使用状态：</p>
                        <select name="useStatus">
                            <option value="">所有</option>
                            <option value="0">未使用</option>
                            <option value="1">已使用</option>
                            <option value="2">已过期</option>
                        </select>

                        <li>
                            <p>订单编号：</p>
                            <input type="text" name="orderSn"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <!--        <div class="btn-group-sm" id="toolbar" role="group">-->
        <!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="mall:history:add">-->
        <!--                <i class="fa fa-plus"></i> 添加-->
        <!--            </a>-->
        <!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"-->
        <!--               shiro:hasPermission="mall:history:edit">-->
        <!--                <i class="fa fa-edit"></i> 修改-->
        <!--            </a>-->
        <!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"-->
        <!--               shiro:hasPermission="mall:history:remove">-->
        <!--                <i class="fa fa-remove"></i> 删除-->
        <!--            </a>-->
        <!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mall:history:export">-->
        <!--                <i class="fa fa-download"></i> 导出-->
        <!--            </a>-->
        <!--        </div>-->
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('mall:history:edit')}]];
    var removeFlag = [[${@permission.hasPermi('mall:history:remove')}]];
    var prefix = ctx + "mall/history";

    $(function () {
        var memberId = $("#memberId").val();

        var options = {
            url: prefix + "/listAll?memberId=" + memberId,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "优惠券使用、领取历史",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                {
                    field: 'couponCode',
                    title: '优惠券编号'
                },
                {
                    field: 'memberNickname',
                    title: '领取人昵称'
                },
                {
                    field: 'getType',
                    title: '领取方式',
                    formatter: function (value, row, index) {
                        if (row.getType === 0) {
                            return "后台赠送";
                        } else {
                            return "主动获取";
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '领取时间'
                },
                {
                    field: 'useStatus',
                    title: '当前状态',
                    formatter: function (value, row, index) {
                        if (row.useStatus === 0) {
                            return "未使用";
                        } else if (row.useStatus === 1) {
                            return "已使用";
                        } else {
                            return "已过期";
                        }
                    }
                },
                {
                    field: 'useTime',
                    title: '使用时间'
                },
                {
                    field: 'orderSn',
                    title: '订单号'
                }
            ]
        };
        $.table.init(options);
    });


    function detailUrl(memberId) {
        $.modal.open("优惠券明细", prefix + "/detail?memberId=" + memberId);
    }
</script>
</body>
</html>